<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Builds and solves a simple inequality-constrained linear program</title>
<link rel="canonical" href="/Users/mcgrant/Projects/CVX/examples/html/simple_LP2.html">
<link rel="stylesheet" href="../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Builds and solves a simple inequality-constrained linear program</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#output">Text output</a>
&nbsp;&nbsp;&nbsp;&nbsp;
Plots
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
echo <span class="string">on</span>

n = 10;
A = randn(2*n,n);
b = randn(2*n,1);
c = randn(n,1);
d = randn;
cvx_begin
   variable <span class="string">x(n)</span>
   dual <span class="string">variables</span> <span class="string">y</span> <span class="string">z</span>
   minimize( c' * x + d )
   subject <span class="string">to</span>
      y : A * x &lt;= b;
cvx_end

echo <span class="string">off</span>
</pre>
<a id="output"></a>
<pre class="codeoutput">
n = 10;
A = randn(2*n,n);
b = randn(2*n,1);
c = randn(n,1);
d = randn;
cvx_begin
   variable x(n)
   dual variables y z
   minimize( c' * x + d )
   subject to
      y : A * x &lt;= b;
cvx_end
 
Calling SDPT3 4.0: 20 variables, 10 equality constraints
   For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------

 num. of constraints = 10
 dim. of linear var  = 20
*******************************************************************
   SDPT3: Infeasible path-following algorithms
*******************************************************************
 version  predcorr  gam  expon  scale_data
    NT      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      prim-obj      dual-obj    cputime
-------------------------------------------------------------------
 0|0.000|0.000|6.6e+01|8.5e+00|2.0e+03| 1.224551e+01  0.000000e+00| 0:0:00| chol  1  1 
 1|0.716|0.990|1.9e+01|1.7e-01|6.1e+02|-7.208277e+00  2.426922e+00| 0:0:00| chol  1  1 
 2|0.920|1.000|1.5e+00|8.5e-03|4.6e+01|-9.397288e-01  3.491295e+00| 0:0:00| chol  1  1 
 3|0.413|1.000|8.7e-01|8.5e-04|3.6e+01|-3.808073e-01  5.218247e+01| 0:0:00| chol  1  1 
 4|0.124|0.458|7.7e-01|5.0e-04|9.8e+01| 1.190177e-01  4.439085e+02| 0:0:00| chol  1  1 
 5|0.052|0.190|7.3e-01|4.0e-04|5.3e+02|-1.343423e-02  5.384123e+03| 0:0:00| chol  1  1 
 6|0.064|1.000|6.8e-01|8.5e-07|1.7e+04| 2.845973e-02  7.408387e+05| 0:0:00| chol  1  2 
 7|0.020|1.000|6.7e-01|2.1e-07|4.2e+06| 2.126749e-02  1.432853e+09| 0:0:00| chol  2  2 
 8|0.099|1.000|6.3e-01|2.2e-02|1.6e+13| 9.235089e-02  1.631005e+14| 0:0:00| chol  2  2 
 9|0.083|1.000|5.8e-01|2.6e+00|2.0e+14| 8.554457e-02  1.955677e+16| 0:0:00|
  sqlp stop: primal problem is suspected of being infeasible
-------------------------------------------------------------------
 number of iterations   =  9
 residual of primal infeasibility      
 certificate (y,Z)      = 6.89e-16
 reldist to infeas.    &lt;= 4.72e-17
 Total CPU time (secs)  = 0.06  
 CPU time per iteration = 0.01  
 termination code       =  1
 DIMACS: 6.9e-01  0.0e+00  4.4e+00  0.0e+00  -1.0e+00  1.0e-02
-------------------------------------------------------------------
 
------------------------------------------------------------
Status: Unbounded
Optimal value (cvx_optval): -Inf
 

echo off
</pre>
</div>
</body>
</html>